package cn.zh.system.service.impl;

import cn.zh.base.service.impl.BaseServiceImpl;
import cn.zh.system.mapper.SystemDictionaryDetailMapper;
import cn.zh.system.mapper.SystemDictionaryTypeMapper;
import cn.zh.system.domain.SystemDictionaryDetail;
import cn.zh.system.domain.SystemDictionaryType;
import cn.zh.system.service.SystemDictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemDictionaryTypeServiceImpl extends BaseServiceImpl<SystemDictionaryType> implements SystemDictionaryTypeService {
    @Autowired
    private SystemDictionaryDetailMapper detailMapper;

    @Autowired
    private SystemDictionaryTypeMapper mapper;

    @Override
    public void delete(Long id) {
        List<SystemDictionaryDetail> details = detailMapper.findAll();
            for (SystemDictionaryDetail detail: details) {
                if (id==detail.getTypesId()) {
                    mapper.delete(id);
                    detailMapper.delete(detail.getId());
                }
            }
    }

}
